const methods = ["cwhLeaveJoinmeetingDicAPP",
    "cwhAttendLeavePermissionJudge",
    "cwhAttendleaveEndDate",
    "cwhAttendleaveDirectbm",
    "cwhAttendleaveBm",
    "cwhAttendleaveHome",
    "signIn",
    "cwhLeavedetailcontentDicAPP",
    "cwhLeaveBySchedule",
    "cwhhalfLeaveArrangeDicAPP",
    "cwhAttendleaveQj",
    "cwhLeavereasonDicAPP",
    "cwhAttendleaveZjqj",
    "cwhSpecialSubjectHome",
    "cwhSpecialSubjectNewspaperSelection",
    "detailcwhSpecialSubjectNewspaperSelection",
    "updateCwhSpecialSubjectNewspaperSelection",
    "cwhSpecialSubjectIsNewspaperSelection",
    "wyBmDetail",
    "updatePersonQjMessage",
    "cwhPersonQjDetail",
    "cwhMeetingFileCategory",
    "cwhMeetingFileInfoDisplay",
    "cwhMeetingFileInfoDetail",
    "cwhMeetingAgendaAPP",
    "cwhScheduleAPP",
    "cwhMeetingrestAPP",
    "cwhMeetingnotesAPP",
    "cwhServicTelAPP",
    "cwhNoticereceivedAPP",
    "cwhReplyNoticAPP",
    "cwhAllNoticeAPP",
    "cwhAllNoticDetailAPP",
    "cwhNoticDetailAPP",
    "signInWeiyuan",
    "qwhNoticeToBeReceived",
    "qwhAllNotifications",
    "qwhReply",
    "qwhNoticeOfMeetingDetails",
    "qwhMeetingAgenda",
    "qwhHomePage",
    "qwhMeetingDateAndStatusAndLeave",
    "qwhMeetingSignUp",
    "qwhMeetingSignUpDetaiil",
    "qwhMeetingLeave",
    "qwhLeavedetailcontentDicAPP",
    "qwhLeavereasonDicAPP",
    "qwhLeaveBySchedule",
    "qwhMeetingLeaveDetail",
    "qwhMeetingFileCategory",
    "qwhMeetingFileInfoDisplay",
    "qwhMeetingFileInfoDetail",
    "toSubmitBook",
    "submitBookStateChange",
    "allEnterInformationShow",
    "uploadPicture",
    "dictionaryList",
    "changeFrontCheckFormInfo",
    "findMonitorFormData",
    "insertMoreForm",
    "updateMoreForm",
    "findMoreForm",
    "moreMultiUpload",
    "updateMonitorAndPicture",
    "showHzMonitorInfo",
    "findyqfkPersonPrimaryId",
    "hzMonitorFormList",
    "showHqInfo",
    "addHqInfo",
    "updateHqInfo",
    "addHzInfo",
    "updateHzInfo",
    "showHzDateList",
    "getHomeData",
    "getBmData",
    "saveBm",
    "saveQJ",
    "detailBmandQj",
    "findListData",
    "getHomeData1",
    "isAgent",
    "getAgentHomeData",
    "agentSign",
    "getAgentAllList",
    "detailAgentPerson",
    "updateAgentPerson",
    "deleteAgentPerson",
    "pOrULogin",
    "queryContent",
    "qwhMeetingSeatArrangeDetail",
    "zhhwAppHome",
    "qwhMeetingFileCategory",
    "getPhotoFile",
    "queryPlatformNotice",
    "createJwt",
    "queryNotificationDetails",
    "queryReportSituation",
    "queryReportDetail",
    "getAllHotelName",
    "getAllReportPerson"]


const files = ["D:/Project/new_znhw/qwh_meetingController/src/main/java/com/gentlesoft/qwh_meeting/controller/Qwh_yqfk_type_mobileController.java",
    "D:/Project/new_znhw/qwh_meetingController/src/main/java/com/gentlesoft/qwh_meeting/controller/Qwh_yqfk_file_mobileController.java",
    "D:/Project/new_znhw/qwh_meetingController/src/main/java/com/gentlesoft/qwh_meeting/controller/Qwh_attendleave_mobileController.java",
    "D:/Project/new_znhw/qwh_meetingController/src/main/java/com/gentlesoft/qwh_meeting/controller/Qwh_attendleave_mobileController.java",
    "D:/Project/new_znhw/qwh_meetingController/src/main/java/com/gentlesoft/qwh_meeting/controller/Qwh_attendleave_mobileController.java",
    "D:/Project/new_znhw/qwh_meetingController/src/main/java/com/gentlesoft/qwh_meeting/controller/Qwh_attendleave_mobileController.java",
    "D:/Project/new_znhw/meeting_roomController/src/main/java/com/gentlesoft/meeting_room/controller/Meeting_room_mobileController.java",
    "D:/Project/new_znhw/meeting_groupController/src/main/java/com/gentlesoft/meeting_group/controller/Meeting_group_mobileController.java",
    "D:/Project/new_znhw/cwh_attendleaveController/src/main/java/com/gentlesoft/cwh_specialsubjectpublic/controller/Cwh_specialsubject_mobileController.java",
    "D:/Project/new_znhw/cwh_attendleaveController/src/main/java/com/gentlesoft/cwh_attendleave/controller/Cwh_attendleave_mobileController.java",
    "D:/Project/new_znhw/cwh_attendleaveController/src/main/java/com/gentlesoft/cwh_attendleave/controller/Cwh_attendleave_mobileController.java",
    "D:/Project/new_znhw/InfoApply_BasicInfoController/src/main/java/com/gentlesoft/InfoApply_Type/controller/Info_apply_type_mobileController.java",
    "D:/Project/new_znhw/qwh_meetingController/src/main/java/com/gentlesoft/qwh_meeting/controller/Qwh_yqfkhq_message_mobileController.java"];


const fs = require('fs');
const methods_file_Map = new Map();

for (let file of files) {
    fs.readFile(file, 'utf-8', function (err, fileContent) {
        // 打印错误结果，文件读取成功 err 值等于 null

        // 打印成功的结果
        // console.log(fileContent);
        for (let methodName of methods) {
            if (fileContent.indexOf(methodName) !== -1) {
                let item = methods_file_Map.get(methodName);
                if (item) {
                    item.add(file.substring(file.lastIndexOf('/') + 1));
                } else {
                    const val = new Set()
                    val.add(file.substring(file.lastIndexOf('/') + 1))
                    methods_file_Map.set(methodName, val)
                }
            }
        }

        if (methods_file_Map.size === 82) {
            const result = new Map();

            methods_file_Map.forEach((item, key) => {
                let prefix = [...item][0]
                prefix = prefix.substring(0, prefix.indexOf('Controller'))
                result.set(key, prefix.toLowerCase() + "/" + key)
            })
            // console.log(result)
            fs.readFile("./会务接口-原始.js", 'utf-8', function (err, data) {

                result.forEach((newstr, oldstr) => {
                    data = data.replace("/" + oldstr + ".do", "/" + newstr + ".do");
                })
                console.log(data)
            });
        }

    });

}


